package com.pllandxzx.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pll.pojo.Menu;
import com.pllandxzx.bean.MenuBean;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @ClassName：MenuMapper
 * @Author: 阿⭐
 * @Date: 2025/6/11 16:52
 * @Description: TODO
 */
@Mapper
public interface MenuMapper extends BaseMapper<Menu> {

    @Select("SELECT * FROM role AS r JOIN permission AS p ON r.role_id = p.role_id " +
            "JOIN menu AS m ON p.menu_id = m.menu_id WHERE r.role_id = ${roleId}")
    List<MenuBean> getMenuByRoleId(@Param("roleId") long roleId);

    @Select("SELECT * FROM menu WHERE menu_id != 0")
    List<MenuBean> getAllMenu();

    @Select("SELECT p.menu_id FROM role AS r JOIN permission AS p ON r.role_id = p.role_id " +
            "JOIN menu AS m ON p.menu_id = m.menu_id WHERE r.role_id = ${roleId}")
    List<Long> getRoleMenus(long roleId);
}
